﻿<UserControl x:Class="Gaiocorp.SLMapViewer.MapControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"
    xmlns:slv="clr-namespace:Silverlight.Validators;assembly=Silverlight.Validators"
    xmlns:slvf="clr-namespace:Silverlight.Validators.Filters;assembly=Silverlight.Validators"
    xmlns:Res="clr-namespace:Gaiocorp.SLMapViewer.Resources"
    xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
    xmlns:liquidTreeView="clr-namespace:Liquid;assembly=Liquid.TreeView">
    <UserControl.Resources>
        <Res:SLMapViewer x:Key="SLMapViewer"></Res:SLMapViewer>    
     </UserControl.Resources>

    <Canvas x:Name="LayoutRoot" Background="White" Height="Auto" Width="Auto" >

        <Canvas x:Name="cnvMap" Background="White" Opacity="1" >

            <Image  x:Name="MapImg" Source=""
                MouseLeftButtonDown="MapImg_MouseLeftButtonDown" 
                MouseLeftButtonUp="MapImg_MouseLeftButtonUp" 
                MouseMove="MapImg_MouseMove"
                MouseLeave="MapImg_MouseLeave"
                LostMouseCapture="MapImg_LostMouseCapture"
                Canvas.Left="0"
                Canvas.Top="0">
                <Image.Resources>
                    <Storyboard x:Name="myStoryboard">
                        <DoubleAnimation Storyboard.TargetName="MapImg" Storyboard.TargetProperty="Opacity" From="0.0" To="1.0" Duration="0:0:1" AutoReverse="False" />
                    </Storyboard>
                </Image.Resources>
            </Image>
            <Rectangle
                    x:Name="rectMap"
                    Canvas.Top="0"
                    Canvas.Left="0"
                    Stroke="Black"
                    StrokeThickness="2"
                    RadiusX = "3"
                    RadiusY = "3">
            </Rectangle>
            <!--</Border>-->
            <Border x:Name="brdToolbar" Background="LightBlue" BorderBrush="Blue"  BorderThickness="1" Width="400"  Height="28" Visibility="Visible">
                <Canvas x:Name="cnvToolbar" Background="LightBlue" Visibility="Visible">
                    <Rectangle
                            x:Name="ZoomInImg_rect"
                            Canvas.Top="1"
                            Canvas.Left="1"
                            Width="24"
                            Height="24"
                            Fill="LightGray"
                            Opacity="0.7"
                            RadiusX = "3"
                            RadiusY = "3"
                            Stroke="Gray"
                            StrokeThickness="2">
                    </Rectangle>
                    <Image  x:Name="ZoomInImg" 
                                Source="Images/viewmag+.png" 
                                Canvas.Top="2" Canvas.Left="2"
                                Width="20"
                                Height="20"
                                ToolTipService.ToolTip="{Binding ZoomInTT, Source={StaticResource SLMapViewer}}"
                                MouseLeftButtonDown="Tool_MouseLeftButtonDown">
                    </Image>
                    <Rectangle
                            x:Name="ZoomOutImg_rect"
                            Canvas.Top="1"
                            Canvas.Left="24"
                            Width="24"
                            Height="24"
                            Fill="LightGray"
                            Opacity="0.7"
                            RadiusX = "3"
                            RadiusY = "3"
                            Stroke="Gray"
                            StrokeThickness="2">
                    </Rectangle>
                    <Image  x:Name="ZoomOutImg" 
                                Source="Images/viewmag-.png" 
                                Canvas.Top="2" Canvas.Left="25"
                                Width="20"
                                Height="20"
                                ToolTipService.ToolTip="{Binding ZoomOutTT, Source={StaticResource SLMapViewer}}"
                                MouseLeftButtonDown="Tool_MouseLeftButtonDown">
                    </Image>
                    <Rectangle
                            x:Name="PanImg_rect"
                            Canvas.Top="1"
                            Canvas.Left="47"
                            Width="24"
                            Height="24"
                            Fill="LightGray"
                            Opacity="0.7"
                            RadiusX = "3"
                            RadiusY = "3"
                            Stroke="Gray"
                            StrokeThickness="2">
                    </Rectangle>
                    <Image  x:Name="PanImg" 
                                Source="Images/pan.png" 
                                Canvas.Top="1" Canvas.Left="48"
                                Width="20"
                                Height="20"
                                ToolTipService.ToolTip="{Binding PanTT, Source={StaticResource SLMapViewer}}"
                                MouseLeftButtonDown="Tool_MouseLeftButtonDown">
                    </Image>
                    <Rectangle
                            x:Name="InitImg_rect"
                            Canvas.Top="1"
                            Canvas.Left="70"
                            Width="24"
                            Height="24"
                            Fill="LightGray"
                            Opacity="0.7"
                            RadiusX = "3"
                            RadiusY = "3"
                            Stroke="Gray"
                            StrokeThickness="2">
                    </Rectangle>
                    <Image  x:Name="InitImg" 
                                Source="Images/init_extent_24.png" 
                                Canvas.Top="2" Canvas.Left="72"
                                Width="20"
                                Height="20"
                                ToolTipService.ToolTip="{Binding FullExtentTT, Source={StaticResource SLMapViewer}}"
                                MouseLeftButtonDown="Button_MouseLeftButtonDown"
                                MouseLeftButtonUp="Button_MouseLeftButtonUp">
                    </Image>
                    <Rectangle
                            x:Name="PrevImg_rect"
                            Canvas.Top="1"
                            Canvas.Left="94"
                            Width="24"
                            Height="24"
                            Fill="LightGray"
                            Opacity="0.7"
                            RadiusX = "3"
                            RadiusY = "3"
                            Stroke="Gray"
                            StrokeThickness="2">
                    </Rectangle>
                    <Image  x:Name="PrevImg" 
                                Source="Images/previous.png" 
                                Canvas.Top="2" Canvas.Left="95"
                                Width="20"
                                Height="20"
                                ToolTipService.ToolTip="{Binding PrevExtentTT, Source={StaticResource SLMapViewer}}"
                                MouseLeftButtonDown="Button_MouseLeftButtonDown"
                                MouseLeftButtonUp="Button_MouseLeftButtonUp">
                    </Image>



                    <Rectangle
                            x:Name="SelectImg_rect"
                            Canvas.Top="1"
                            Canvas.Left="118"
                            Width="24"
                            Height="24"
                            Fill="LightGray"
                            Opacity="0.7"
                            RadiusX = "3"
                            RadiusY = "3"
                            Stroke="Gray"
                            StrokeThickness="2">
                    </Rectangle>
                    <Image  x:Name="SelectImg" 
                                Source="Images/14_selectnodes.png" 
                                Width="20"
                                Height="20"
                                ToolTipService.ToolTip="{Binding SelectTT, Source={StaticResource SLMapViewer}}"
                                Canvas.Top="2" Canvas.Left="119"
                                MouseLeftButtonDown="Tool_MouseLeftButtonDown">
                    </Image>
                    <Rectangle
                            x:Name="InfoImg_rect"
                            Canvas.Top="1"
                            Canvas.Left="142"
                            Width="24"
                            Height="24"
                            Fill="LightGray"
                            Opacity="0.7"
                            RadiusX = "3"
                            RadiusY = "3"
                            Stroke="Gray"
                            StrokeThickness="2">
                    </Rectangle>
                    <Image  x:Name="InfoImg" 
                            Source="Images/info.png" 
                            Canvas.Top="2" Canvas.Left="143"
                            Width="20"
                            Height="20"
                            ToolTipService.ToolTip="{Binding IdentifyTT, Source={StaticResource SLMapViewer}}"
                            MouseLeftButtonDown="Tool_MouseLeftButtonDown">
                    </Image>
                    <Rectangle
                            x:Name="TabImg_rect"
                            Canvas.Top="1"
                            Canvas.Left="170"
                            Width="24"
                            Height="24"
                            Fill="LightGray"
                            Opacity="0.7"
                            RadiusX = "3"
                            RadiusY = "3"
                            Stroke="Gray"
                            StrokeThickness="2">
                    </Rectangle>
                    <Image  x:Name="TabImg" 
                            Source="Images/table_20.png" 
                            Canvas.Top="3" Canvas.Left="171"
                            Width="19"
                            Height="19"
                            ToolTipService.ToolTip="{Binding AttrTableTT, Source={StaticResource SLMapViewer}}"
                            MouseLeftButtonDown="Button_MouseLeftButtonDown"
                            MouseLeftButtonUp="Button_MouseLeftButtonUp">
                    </Image>
                    <Rectangle
                            x:Name="QueryAttrsImg_rect"
                            Canvas.Top="1"
                            Canvas.Left="194"
                            Width="24"
                            Height="24"
                            Fill="LightGray"
                            Opacity="0.7"
                            RadiusX = "3"
                            RadiusY = "3"
                            Stroke="Gray"
                            StrokeThickness="2">
                    </Rectangle>
                    <Image  x:Name="QueryAttrsImg" 
                            Source="Images/querybyattrs_24.png" 
                            Canvas.Top="3" Canvas.Left="195"
                            Width="19"
                            Height="19"
                            ToolTipService.ToolTip="{Binding QueryByAttrsTT, Source={StaticResource SLMapViewer}}"
                            MouseLeftButtonDown="Button_MouseLeftButtonDown"
                            MouseLeftButtonUp="Button_MouseLeftButtonUp">
                    </Image>
                    <Rectangle
                            x:Name="AddPntImg_rect"
                            Canvas.Top="1"
                            Canvas.Left="220"
                            Width="24"
                            Height="24"
                            Fill="LightGray"
                            Opacity="0.7"
                            RadiusX = "3"
                            RadiusY = "3"
                            Stroke="Gray"
                            StrokeThickness="2">
                    </Rectangle>
                    <Image  x:Name="AddPntImg" 
                            Source="Images/pin_24.png" 
                            Canvas.Top="2" Canvas.Left="221"
                            Width="20"
                            Height="20"
                            ToolTipService.ToolTip="{Binding AddPointTT, Source={StaticResource SLMapViewer}}"
                            MouseLeftButtonDown="Tool_MouseLeftButtonDown">
                    </Image>
                    <Rectangle
                            x:Name="RemovePntImg_rect"
                            Canvas.Top="1"
                            Canvas.Left="244"
                            Width="24"
                            Height="24"
                            Fill="LightGray"
                            Opacity="0.7"
                            RadiusX = "3"
                            RadiusY = "3"
                            Stroke="Gray"
                            StrokeThickness="2">
                    </Rectangle>
                    <Image  x:Name="RemovePntImg" 
                            Source="Images/remove_pin_24.png" 
                            Canvas.Top="2" Canvas.Left="245"
                            Width="20"
                            Height="20"
                            ToolTipService.ToolTip="{Binding RemovePointTT, Source={StaticResource SLMapViewer}}"
                            MouseLeftButtonDown="Button_MouseLeftButtonDown"
                            MouseLeftButtonUp="Button_MouseLeftButtonUp">
                    </Image>
                    <Rectangle
                            x:Name="LegendImg_rect"
                            Canvas.Top="1"
                            Canvas.Left="270"
                            Width="24"
                            Height="24"
                            Fill="LightGray"
                            Opacity="0.7"
                            RadiusX = "3"
                            RadiusY = "3"
                            Stroke="Gray"
                            StrokeThickness="2">
                    </Rectangle>
                    <Image  x:Name="LegendImg" 
                            Source="Images/view_detailed.png" 
                            Canvas.Top="2"
                            Width="20"
                            Height="20"
                            Canvas.Left="271"
                            ToolTipService.ToolTip="{Binding LegendBtnTT, Source={StaticResource SLMapViewer}}"
                            MouseLeftButtonDown="Button_MouseLeftButtonDown"
                            MouseLeftButtonUp="Button_MouseLeftButtonUp">
                    </Image>
                    <Rectangle
                            x:Name="HyperlImg_rect"
                            Canvas.Top="1"
                            Canvas.Left="294"
                            Width="24"
                            Height="24"
                            Fill="LightGray"
                            Opacity="0.7"
                            RadiusX = "3"
                            RadiusY = "3"
                            Stroke="Gray"
                            StrokeThickness="2">
                    </Rectangle>
                    <Image  x:Name="HyperlImg" 
                            Source="Images/hyperlink_24.png" 
                            Canvas.Top="3"
                            Width="19"
                            Height="19"
                            Canvas.Left="295"
                            ToolTipService.ToolTip="{Binding HyperlinkToolTT, Source={StaticResource SLMapViewer}}"
                            MouseLeftButtonDown="Tool_MouseLeftButtonDown">
                    </Image>
                    <Rectangle
                            x:Name="MeasureImg_rect"
                            Canvas.Top="1"
                            Canvas.Left="318"
                            Width="24"
                            Height="24"
                            Fill="LightGray"
                            Opacity="0.7"
                            RadiusX = "3"
                            RadiusY = "3"
                            Stroke="Gray"
                            StrokeThickness="2">
                    </Rectangle>
                    <Image  x:Name="MeasureImg" 
                            Source="Images/Measure_24.png" 
                            Canvas.Top="3"
                            Width="19"
                            Height="19"
                            Canvas.Left="319"
                            ToolTipService.ToolTip="{Binding MeasureToolTT, Source={StaticResource SLMapViewer}}"
                            MouseLeftButtonDown="Tool_MouseLeftButtonDown">
                    </Image>
                    <Rectangle
                            x:Name="PrintImg_rect"
                            Canvas.Top="1"
                            Canvas.Left="342"
                            Width="24"
                            Height="24"
                            Fill="LightGray"
                            Opacity="0.7"
                            RadiusX = "3"
                            RadiusY = "3"
                            Stroke="Gray"
                            StrokeThickness="2">
                    </Rectangle>
                    <Image  x:Name="PrintImg" 
                            Source="Images/print_24.png" 
                            Canvas.Top="3"
                            Width="19"
                            Height="19"
                            Canvas.Left="343"
                            ToolTipService.ToolTip="{Binding PrintBtnTT, Source={StaticResource SLMapViewer}}"
                            MouseLeftButtonDown="Button_MouseLeftButtonDown"
                            MouseLeftButtonUp="Button_MouseLeftButtonUp">
                    </Image>
                    <Rectangle
                            x:Name="CreatePntImg_rect"
                            Canvas.Top="1"
                            Canvas.Left="363"
                            Width="24"
                            Height="24"
                            Fill="LightGray"
                            Opacity="0.7"
                            RadiusX = "3"
                            RadiusY = "3"
                            Stroke="Gray"
                            StrokeThickness="2"
                            Visibility="Collapsed" >
                    </Rectangle>
                    <Image  x:Name="CreatePntImg" 
                            Source="Images/bookmark_add.png" 
                            Canvas.Top="2" Canvas.Left="364"
                            Width="20"
                            Height="20"
                            ToolTipService.ToolTip="{Binding AddPointTT, Source={StaticResource SLMapViewer}}"
                            MouseLeftButtonDown="Tool_MouseLeftButtonDown"
                            Visibility="Collapsed">
                    </Image>
                </Canvas>
            </Border>
            <!-- 
                The rectangle to be displayed when clicking and dragging on the map 
            -->
            <Canvas x:Name="cnvRectCanvas" 
                        Background="White">
                <Rectangle
                        x:Name="dynrectangle"
                        Canvas.Top="-50"
                        Width="50"
                        Height="50"
                        Fill="Yellow"
                        Opacity="0.7"
                        Stroke="Red"
                        StrokeThickness="2">
                </Rectangle>
            </Canvas>
            <!-- 
                The line to use for the measure tool 
            -->
            <Line x:Name="UserMeasureLine" Stroke="Black" StrokeThickness="1"></Line>
            <Grid x:Name="gridMeasureToolTip" ShowGridLines="False" Visibility="Collapsed" Width="50" Background="Yellow">
                <Grid.RowDefinitions>
                    <RowDefinition></RowDefinition>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition></ColumnDefinition>
                </Grid.ColumnDefinitions>
                <!--<TextBlock x:Name="txbMeasLabel" Grid.Column="0" Grid.Row="0" HorizontalAlignment="Right" VerticalAlignment="Top"  Text="Mήκος:" Foreground="Black" />-->
                <TextBlock x:Name="txbMeasLength" Text="" Grid.Row="0" Grid.Column="0" Visibility="Visible" ></TextBlock>
            </Grid>
            <!-- Hidden fields -->
            <Grid x:Name="gridDebug" ShowGridLines="true" Width="400" Canvas.Top="60">
                <Grid.RowDefinitions>
                    <RowDefinition></RowDefinition>
                    <RowDefinition></RowDefinition>
                    <RowDefinition></RowDefinition>
                    <RowDefinition></RowDefinition>
                    <RowDefinition></RowDefinition>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition></ColumnDefinition>
                    <ColumnDefinition></ColumnDefinition>
                    <ColumnDefinition></ColumnDefinition>
                    <ColumnDefinition></ColumnDefinition>
                </Grid.ColumnDefinitions>
                <TextBox x:Name="stxtXMin" Grid.Row="0" Grid.Column="0" Text=""></TextBox>
                <TextBox x:Name="stxtXMax" Grid.Row="0" Grid.Column="1" Text=""></TextBox>
                <TextBox x:Name="stxtYMin" Grid.Row="0" Grid.Column="2" Text=""></TextBox>
                <TextBox x:Name="stxtYMax" Grid.Row="0" Grid.Column="3" Text=""></TextBox>
                <TextBox x:Name="stxtTest1" Grid.Row="1" Grid.Column="0" Text="{Binding Test, Source={StaticResource SLMapViewer}}" Canvas.Top="100"></TextBox>
                <TextBox x:Name="stxtActiveTool" Text="NONE" Grid.Row="1" Grid.Column="1"></TextBox>
                <TextBox x:Name="stxtActiveLayer" Text="" Grid.Row="1" Grid.Column="2"></TextBox>
                <TextBox x:Name="stxtActiveLayerName" Text="" Grid.Row="1" Grid.Column="3"></TextBox>
                <TextBox x:Name="stxtRequest" Text="" Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="4" TextChanged="stxtRequest_TextChanged"></TextBox>
                <TextBox x:Name="stxtResponse" Text="" Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="4" Visibility="Visible" Canvas.Top="60" TextWrapping="Wrap"></TextBox>
                <TextBox x:Name="stxtHasSelection" Text="" Grid.Row="4" Grid.Column="0"></TextBox>
            </Grid>
            <!-- 
                Status Grid 
                -->
            <Border x:Name="brdStatus" Background="Beige" Opacity="1" BorderBrush="Black" Height="20" BorderThickness="2" Visibility="Visible">
                <Grid x:Name="gridStatus" Background="Beige" Opacity="1" ShowGridLines="False">
                    <Grid.RowDefinitions>
                        <RowDefinition></RowDefinition>
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*"></ColumnDefinition>
                        <ColumnDefinition Width="50"></ColumnDefinition>
                        <ColumnDefinition Width="50"></ColumnDefinition>
                        <ColumnDefinition Width="*"></ColumnDefinition>
                    </Grid.ColumnDefinitions>
                    <slv:ValidatorManager x:Name="Group1"></slv:ValidatorManager>
                    <TextBlock x:Name="txbLayerInfo" Grid.Column="0" Grid.Row="0" HorizontalAlignment="Left" VerticalAlignment="Top"  Text="" Foreground="Black" />
                    <TextBlock x:Name="txbScale" Grid.Column="1" Grid.Row="0" HorizontalAlignment="Right" VerticalAlignment="Top"  Text="{Binding Scale, Source={StaticResource SLMapViewer}}" Foreground="Black" />
                    <TextBox x:Name="txtScale" 
                            Opacity="1" Background="White" 
                            Grid.Column="2" Grid.Row="0" 
                            Padding="0,0,0,0"
                            HorizontalAlignment="Left" VerticalAlignment="Top" 
                            Text="" Foreground="Black" KeyDown="txtScale_KeyDown"
                            slvf:TextBoxFilterService.Filter="Decimal">
                    </TextBox>
                    <TextBlock x:Name="stxtStatusBar" Text="" HorizontalAlignment="Right" TextAlignment="Right" Grid.Column="3" Grid.Row="0" />
                </Grid>
            </Border>
            <!-- 
                Query By Attributes 
            -->
            <Border x:Name="brdQuery" Background="Silver" Opacity="1" BorderBrush="Black" BorderThickness="2" Visibility="Collapsed">
                <ScrollViewer x:Name="Sv0" 
                                        Margin="0,0,0,0" 
                                        VerticalScrollBarVisibility="Auto" 
                                        HorizontalScrollBarVisibility="Auto"
                                        >
                    <Grid x:Name="gridQuery" Background="Silver" ShowGridLines="False" >
                        <Grid.RowDefinitions>
                            <RowDefinition></RowDefinition>
                            <RowDefinition></RowDefinition>
                            <RowDefinition></RowDefinition>
                            <RowDefinition></RowDefinition>
                            <RowDefinition></RowDefinition>
                            <RowDefinition></RowDefinition>
                            <RowDefinition></RowDefinition>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="100"></ColumnDefinition>
                            <ColumnDefinition Width="200"></ColumnDefinition>

                        </Grid.ColumnDefinitions>
                        <Rectangle x:Name="RectQTitle" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="4" Fill="Blue" Height="20"></Rectangle>
                        <TextBlock x:Name="txbQTitle" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="4" Text="{Binding QueryByAttrsTitle, Source={StaticResource SLMapViewer}}" Foreground="White"  Margin="5"/>
                        <TextBlock x:Name="txbQLayers" Grid.Row="1" Grid.Column="0" Text="{Binding LayerCboLabel, Source={StaticResource SLMapViewer}}" Foreground="Black"  Margin="5"/>
                        <ComboBox x:Name="cboLayers" 
                            Grid.Row="1" Grid.Column="1"
                            Grid.ColumnSpan="1" 
                            SelectionChanged="cboLayers_SelectionChanged"
                            Width="150" Margin="5">
                        </ComboBox>
                        <TextBlock x:Name="txbQAttrs" Grid.Row="2" Grid.Column="0" Text="{Binding AttributesLabel, Source={StaticResource SLMapViewer}}" Foreground="Black"  Margin="5"/>
                        <ListBox x:Name="lsAttrs" 
                            Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="1" 
                            Padding="5"
                            SelectionChanged="lsAttrs_SelectionChanged"
                            MouseLeftButtonUp="lsAttrs_MouseLeftButtonUp"></ListBox>
                        <TextBlock x:Name="txbOps" Grid.Row="3" Grid.Column="0" Text="{Binding OperatorsLabel, Source={StaticResource SLMapViewer}}" Foreground="Black"  Margin="5"/>
                        <ComboBox x:Name="cboOps" 
                            Grid.Row="3" Grid.Column="1"
                            Grid.ColumnSpan="1"
                            SelectionChanged="cboOps_SelectionChanged"
                            Width="150" Margin="5">
                            <ComboBoxItem Content="="></ComboBoxItem>
                            <ComboBoxItem Content="&lt;&gt;"></ComboBoxItem>
                            <ComboBoxItem Content="&gt;"></ComboBoxItem>
                            <ComboBoxItem Content="&lt;"></ComboBoxItem>
                            <ComboBoxItem Content="&gt;="></ComboBoxItem>
                            <ComboBoxItem Content="&lt;="></ComboBoxItem>
                            <ComboBoxItem Content="LIKE"></ComboBoxItem>
                            <ComboBoxItem Content="AND"></ComboBoxItem>
                            <ComboBoxItem Content="OR"></ComboBoxItem>
                            <ComboBoxItem Content="NOT"></ComboBoxItem>
                            <ComboBoxItem Content="()"></ComboBoxItem>
                        </ComboBox>
                        <TextBlock x:Name="txbQSelect" Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="2" HorizontalAlignment="Left" Text="" Foreground="Black"  Margin="5"/>
                        <TextBlock x:Name="txbQValue" Grid.Row="5" Grid.Column="0" Text="{Binding ValueLabel, Source={StaticResource SLMapViewer}}" Foreground="Black"  Margin="5"/>
                        <TextBox x:Name="txtQuery" 
                            Text="" TextWrapping="Wrap" 
                            Grid.Row="5" Grid.Column="1" Grid.ColumnSpan="3" Height="100" Margin="5" ></TextBox>
                        <Button x:Name="btnCloseQuery" 
                            Content="{Binding Close, Source={StaticResource SLMapViewer}}" 
                            Width="70" 
                            Margin="5" 
                            Grid.Row="6" 
                            Grid.Column="0"
                            Grid.ColumnSpan="4"
                            IsEnabled="True"
                            HorizontalAlignment="Left"
                            Click="btnCloseQuery_Click"></Button>
                        <Button x:Name="btnDoQuery" 
                            Content="{Binding DoQuery, Source={StaticResource SLMapViewer}}" 
                            Width="70" 
                            Margin="5" 
                            Grid.Row="6" 
                            Grid.Column="1"
                            Grid.ColumnSpan="1"
                            IsEnabled="True"
                            HorizontalAlignment="Right"
                            Click="btnDoQuery_Click"></Button>
                    </Grid>

                </ScrollViewer>
            </Border>
            <Border x:Name="brdResults" Background="Beige" Opacity="1" BorderBrush="Black" Height="Auto" Width="Auto" BorderThickness="2" Visibility="Collapsed">
                <Grid x:Name="gridResults" Background="White">
                    <Grid.RowDefinitions>
                        <RowDefinition></RowDefinition>
                        <RowDefinition></RowDefinition>
                        <RowDefinition></RowDefinition>
                        <RowDefinition></RowDefinition>
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition></ColumnDefinition>
                        <ColumnDefinition></ColumnDefinition>
                        <ColumnDefinition></ColumnDefinition>
                    </Grid.ColumnDefinitions>
                    <Rectangle x:Name="RectTitle2" Grid.Row="0" Grid.ColumnSpan="3" Fill="Blue" Height="20"></Rectangle>
                    <TextBlock x:Name="ResultsTitle" Grid.Row="0" Grid.ColumnSpan="2" Text="{Binding SearchResultsTitle, Source={StaticResource SLMapViewer}}" Foreground="White"  Margin="5"/>
                    <Button x:Name="btnCloseResult" 
                                Grid.Row="3"
                                Grid.Column="3" 
                                Width="80" Margin="3"
                                Content="{Binding Close, Source={StaticResource SLMapViewer}}"
                                Click="xbtnCloseResults_Click">
                    </Button>
                    <Image  x:Name="imgShowExtDetails" 
                                Source="Images/list.png" 
                                Margin="5,5,5,5" 
                                Grid.Row="1" 
                                Grid.Column="0"
                                Width="20" Height="20"
                                ToolTipService.ToolTip="{Binding ShowDetailsBtn, Source={StaticResource SLMapViewer}}"
                                MouseLeftButtonDown="imgShowExtDetails_MouseLeftButtonDown">
                    </Image>
                    <Image  x:Name="imgZoomToResult" 
                                    Source="Images/internet_networking.png" 
                                    Margin="5,5,5,5" 
                                    Grid.Row="1" 
                                    Grid.Column="1"
                                    Width="20" Height="20"
                                    ToolTipService.ToolTip="{Binding ZoomToSelected, Source={StaticResource SLMapViewer}}"
                                    MouseLeftButtonDown="imgZoomToResult_MouseLeftButtonDown">
                    </Image>
                    <ScrollViewer x:Name="Sv1" 
                                    Margin="0,0,0,0" 
                                    VerticalScrollBarVisibility="Auto" 
                                    HorizontalScrollBarVisibility="Auto"
                                    Grid.Column="0" Grid.Row="2"
                                    Grid.ColumnSpan="3">
                        <data:DataGrid x:Name="gridDataResults"
                                Grid.Column="0"  
                                Grid.Row="2"
                                SelectedIndex="-1"  
                                AutoGenerateColumns="False" 
                                SelectionMode="Single" 
                                IsReadOnly="True"
                                SelectionChanged="gridDataResults_SelectionChanged" >
                        </data:DataGrid>
                    </ScrollViewer>
                    <TextBlock x:Name="ResultsCount" Grid.Row="3" Grid.ColumnSpan="2" Text="" Foreground="Black"  Margin="5"/>
                </Grid>
            </Border>
        </Canvas>
        <!-- 
                Legend
        -->
        <Canvas x:Name="cnvLegend" Background="White" Visibility="Collapsed" Height="Auto"  >
            <Border x:Name="brdLegend" CornerRadius="7" Background="Silver" BorderBrush="Black" BorderThickness="2">
                <Grid x:Name="gridLegCont">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="25"/>
                        <RowDefinition Height="50"/>
                        <RowDefinition Height="Auto"/>
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="110"></ColumnDefinition>
                        <ColumnDefinition Width="120"></ColumnDefinition>
                        <ColumnDefinition Width="70"></ColumnDefinition>
                    </Grid.ColumnDefinitions>
                    <Rectangle x:Name="RectTitle" Grid.Row="0" Grid.ColumnSpan="3" Fill="Blue" Height="20"></Rectangle>
                    <TextBlock x:Name="LegendTitle" Grid.Row="0" Grid.ColumnSpan="3" Text="{Binding Legend, Source={StaticResource SLMapViewer}}" Foreground="White"  Margin="5"/>
                    <Button x:Name="xbtnCloseLegend" HorizontalAlignment="Right"
                                Content="{Binding Close, Source={StaticResource SLMapViewer}}"
                                Width="70" Height="25" 
                                Grid.Row="1" Grid.Column="2"
                                Click="xbtnCloseLegend_Click">
                    </Button>
                    <Grid x:Name="gridLegend"  ShowGridLines="True" Visibility="Visible" Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="3">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"></ColumnDefinition>
                        </Grid.ColumnDefinitions>
                        <!-- 
                            TODO: Replace this with Silverlight 3 tree control 
                        -->
                        <liquidTreeView:Tree x:Name="treeLegend" Grid.Row="0" Grid.Column="0" BorderThickness="1" EnableLines="True" Background="Silver"
                                                EnableDragAndDrop="False" Width="300" 
                                                EnableCheckboxes="True" SelectionChanged="treeLegend_NodeClick" NodeCheckChanged="LayerNode_NodeCheckChanged" 
                                                >

                        </liquidTreeView:Tree>
                    </Grid>
                </Grid>
            </Border>
        </Canvas>
        <!-- 
                Wait window 
        -->
        <Border x:Name="brdWait" Background="Beige" Opacity="0.8" BorderBrush="Black"  BorderThickness="4" Width="220" Height="110" Visibility="Collapsed">
            <Canvas x:Name="WaitBanner" Background="Beige" Visibility="Visible">
                <Image x:Name="WaitImg" 
                            Source="Images/reload_48.png" 
                            Canvas.Top="26" Canvas.Left="10">
                </Image>
                <TextBox x:Name="stxtPleaseWait" Text="{Binding PleaseWait, Source={StaticResource SLMapViewer}}" Canvas.Top="50" Canvas.Left="60" Background="Beige" Visibility="Visible" BorderThickness="0" ></TextBox>
            </Canvas>
        </Border>
        <!-- 
                Print Dialog 
        -->
        <Border x:Name="brdPrint" Opacity="1" BorderBrush="Black" BorderThickness="2" Visibility="Collapsed">
            <Grid x:Name="gridPrint" Background="Beige" Opacity="1" ShowGridLines="false">
                <Grid.RowDefinitions>
                    <RowDefinition></RowDefinition>
                    <RowDefinition></RowDefinition>
                    <RowDefinition></RowDefinition>
                    <RowDefinition></RowDefinition>
                    <RowDefinition></RowDefinition>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition></ColumnDefinition>
                    <ColumnDefinition></ColumnDefinition>
                </Grid.ColumnDefinitions>
                <slv:ValidatorManager x:Name="Group2"></slv:ValidatorManager>
                <Rectangle x:Name="RectPrintTitle" RadiusX="5" RadiusY="5" Grid.Row="0" Grid.ColumnSpan="2" Fill="CadetBlue" Height="20" Margin="2 2 2 2"></Rectangle>
                <TextBlock x:Name="txbPrintWinTitle" Grid.Row="0" Grid.ColumnSpan="2" Text="{Binding PrintOptionsTitle, Source={StaticResource SLMapViewer}}" Foreground="White"  Margin="5"/>
                <TextBlock x:Name="txbPrintTitle" Grid.Column="0" Grid.Row="1" Width="80" HorizontalAlignment="Right" VerticalAlignment="Top"  Text="{Binding MapTitle, Source={StaticResource SLMapViewer}}" Foreground="Black" Margin="2 2 2 2" />
                <TextBox x:Name="txtPrintTitle" 
                            Opacity="1" Background="White" 
                            Grid.Column="1" Grid.Row="1" 
                            Width="200" 
                            HorizontalAlignment="Left" VerticalAlignment="Top" 
                            Padding="0 0 0 0" 
                            Text="" Foreground="Black">
                </TextBox>
                <TextBlock x:Name="txbPrintSize" Grid.Column="0" Grid.Row="2" Width="100" HorizontalAlignment="Right" VerticalAlignment="Top"  Text="{Binding PaperSize, Source={StaticResource SLMapViewer}}" Foreground="Black" Margin="2 2 2 2" />
                <ComboBox x:Name="cboPaperSizes" 
                            Grid.Row="2" Grid.Column="1" HorizontalAlignment="Left"
                            Width="150" Margin="0" SelectedIndex="0">
                    <ComboBoxItem Content="A4 LandScape" Tag="A4L"></ComboBoxItem>
                    <ComboBoxItem Content="A4 Portait" Tag="A4P"></ComboBoxItem>
                    <ComboBoxItem Content="A3 LandScape" Tag="A3L"></ComboBoxItem>
                    <ComboBoxItem Content="A3 Portait" Tag="A3P"></ComboBoxItem>
                </ComboBox>
                <TextBlock x:Name="txbPrintScale" Grid.Column="0" Grid.Row="3" Width="90" HorizontalAlignment="Right" VerticalAlignment="Top"  Text="{Binding Scale, Source={StaticResource SLMapViewer}}" Foreground="Black" Margin="2 2 2 2"/>
                <TextBox x:Name="txtPrintScale" 
                            Opacity="1" Background="White" 
                            Grid.Column="1" Grid.Row="3" 
                            Width="80" 
                            HorizontalAlignment="Left" VerticalAlignment="Top" 
                            Padding="0 0 0 0" 
                            Text="" Foreground="Black"
                            slvf:TextBoxFilterService.Filter="Decimal">
                </TextBox>
                <Button x:Name="btnPrint" 
                        Content="{Binding Print, Source={StaticResource SLMapViewer}}" 
                        Width="70" 
                        Margin="5,5,5,5" 
                        Grid.Row="4" 
                        Grid.Column="0"
                        IsEnabled="True"
                        HorizontalAlignment="Left"
                        Click="btnPrint_Click"></Button>
                <Button x:Name="btnPrintClose" 
                        Content="{Binding Close, Source={StaticResource SLMapViewer}}" 
                        Width="70" 
                        Margin="5,5,5,5" 
                        Grid.Row="4" 
                        Grid.Column="1"
                        IsEnabled="True"
                        HorizontalAlignment="Right"
                        Click="btnPrintClose_Click"></Button>
            </Grid>
        </Border>
        <!-- 
                Error window 
        -->
        <Border x:Name="brdError" BorderBrush="Black"  BorderThickness="1"  Visibility="Collapsed" Width="370" Height="230">
            <!--<Canvas x:Name="cnvError" Background="Silver" Visibility="Visible">-->
            <Grid x:Name="gridError" Opacity="1" ShowGridLines="False" Background="Silver">
                <Grid.RowDefinitions>
                    <RowDefinition Height="30"></RowDefinition>
                    <RowDefinition Height="150"></RowDefinition>
                    <RowDefinition Height="50"></RowDefinition>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="70"></ColumnDefinition>
                    <ColumnDefinition Width="300"></ColumnDefinition>
                </Grid.ColumnDefinitions>

                <Rectangle x:Name="RectErrTitle" RadiusX="5" RadiusY="5" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" Fill="Blue" Height="20" Margin="2 2 2 2"></Rectangle>
                <TextBlock x:Name="txbErrTitle" Grid.Row="0" Grid.ColumnSpan="2" Grid.Column="0" Text="{Binding ErrorOccured, Source={StaticResource SLMapViewer}}" Foreground="White"  Margin="5"/>
                <Image  x:Name="ErrorImg" 
                            Source="Images/error.png" 
                            Grid.Row="1" Grid.Column="0"
                            HorizontalAlignment="Center" VerticalAlignment="Center">

                </Image>
                <ScrollViewer x:Name="SvErr" Width="295" 
                                        Margin="0,0,0,0" Grid.Row="1" Grid.Column="1"
                                        VerticalScrollBarVisibility="Auto" 
                                        HorizontalScrollBarVisibility="Auto"
                                        >
                    <TextBlock x:Name="txbErrBody" Grid.Row="1" Grid.Column="1" Text="" TextWrapping="Wrap" Margin="5"/>
                </ScrollViewer>
                <Button x:Name="btnErrorClose" 
                        Content="{Binding OK, Source={StaticResource SLMapViewer}}" 
                        Width="70"
                        Height="30" 
                        Margin="5,5,5,5" 
                        Grid.Row="2" 
                        Grid.Column="0"
                        Grid.ColumnSpan="2"
                        IsEnabled="True"
                        HorizontalAlignment="Center"
                        Click="btnErrorClose_Click"></Button>
                <!--</Canvas>-->
            </Grid>
        </Border>
    </Canvas>
</UserControl>
